import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render, formattingDay, formattingMin, formatTimestamp } from '/@/utils/common/renderUtils';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';
import { defHttp } from '/@/utils/http/axios';
//列表数据
export const columns : BasicColumn[] = [
	/* 	{
			title: '是否删除',
			align: "center",
			dataIndex: 'trash'
		}, */
	/* 	{
			title: '类型',
			align: "center",
			dataIndex: 'type',
			customRender: ({ text }) => {
			
				if (text == 'Product') return '产品'
				if (text == 'TravelLine') return '拼车'
				if (text == 'Group') return '常规大团'
			}
		}, */
	{
		title: '行程名称',
		align: "center",
		dataIndex: 'extinfors',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.itemTitle
		}
	},
	{
		title: '开始时间',
		align: "center",
		dataIndex: 'startdate',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '结束时间',
		align: "center",
		dataIndex: 'enddate',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '排序',
		align: "center",
		dataIndex: 'sortnum'
	},
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '早鸟价截至时间',
		align: "center",
		dataIndex: 'priceexpiretime',
		customRender: ({ text }) => {
			if (text == 0 || !text) return ''
			return formattingMin(text)
		}
	},
	{
		title: '修改时间',
		align: "center",
		dataIndex: 'modifytime',
		customRender: ({ text }) => {
			if (text == 0 || !text) return ''
			return formattingMin(text)
		}
	},
	{
		title: '原价',
		align: "center",
		dataIndex: 'originprice'
	},
	{
		title: '早鸟价',
		align: "center",
		dataIndex: 'activeprice'
	},
	/* 	{
			title: '主标题',
			align: "center",
			dataIndex: 'titlegroup',
			customRender: ({ text }) => {
				let title = JSON.parse(text)
				return title.mainTitle
			},
			ellipsis: true
		},
		{
			title: '副标题',
			align: "center",
			dataIndex: 'titlegroup',
			customRender: ({ text }) => {
				let title = JSON.parse(text)
				return title.secondTitle
			},
			ellipsis: true
		}, */
	{
		title: '图片',
		align: "center",
		dataIndex: 'images',
		customRender: ({ text }) => {
			if (text == 0 || text == '[]') return ''
			let imgs = JSON.parse(text)
			return render.renderImage({ text: imgs[0] })
		},
	},
	/*	{
			title: '其他信息',
			align: "center",
			dataIndex: 'extinfors'
		},*/
];

export const activityColumns : BasicColumn[] = [
	{
		title: '标题',
		align: "center",
		dataIndex: 'gtitle'
	}, {
		title: '模板',
		align: "center",
		dataIndex: 'gtype'
	}, {
		title: '标题',
		align: "center",
		dataIndex: 'gtitle'
	},

]


//查询数据
export const searchFormSchema : FormSchema[] = [
];
//表单数据
export const formSchema : FormSchema[] = [
	/* 	{
			label: '是否删除',
			field: 'trash',
			component: 'Input',
			dynamicRules: ({ model, schema }) => {
				return [
					{ required: true, message: '请输入是否删除!' },
				];
			},
		}, */
	{
		label: '类型',
		field: 'type',
		component: 'JDictSelectTag',
		componentProps: {
			//dictCode: 'week_activity_type'
			options: [
				{ label: '产品', value: 'Product' },
				{ label: '拼车', value: 'TravelLine' },
				{ label: '常规大团', value: 'Group' }
			]
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择类型!' },
			];
		},
	},
	{
		label: '产品',
		field: 'itemid',
		component: 'JSearchSelect',
		componentProps: {
			dict: 'couple_shop_pdt,title,id',
			acync: true
		},
		show: ({ values }) => {
			return values.type == 'Product'

		}
	},
	{
		label: '选择类别',
		field: 'typeAcitvity',
		component: "Input",
		slot: 'selectActivityType',
		required: true
	},
	//这里需要选出发城市，游玩天数，目的地景点，根据这三个来确认选择游玩线路
	/* 	{
			label: '目的地景点',
			field: 'destination',
			component: 'JSearchSelect',
			componentProps: {
				dict: 'BS_Scenic,title,id',
				pageSize: 10,
				async: true
			},
			/* 	dynamicRules: ({ model, schema }) => {
					return [
						{ required: true, message: '请选择目的地景点。!' },
					];
				}, */
	/* dynamicDisabled: ({ values }) => {
		return values.isUpdate == true
	}, 
	show: ({ values }) => {
		return values.type == 'TravelLine' || values.type == 'Group'
	}
}, */
	/* 	{
			label: '游玩天数',
			field: 'travelDays',
			component: 'InputNumber',
			show: ({ values }) => {
				return values.type == 'TravelLine' || values.type == 'Group'
			}
			//	dynamicDisabled: true
		}, */
	/* 	{
			label: '出发日期',
			field: 'startdateStr',
			component: 'DatePicker',
			show: ({ values }) => {
				return values.type == 'TravelLine' || values.type == 'Group'
			}
		}, */
	/* 	{
			label: '出发城市',
			field: 'cityId',
			component: 'JTreeDict',
			componentProps: { async: true, parentCode: 'A02' },
			show: ({ values }) => {
				return values.type == 'TravelLine' || values.type == 'Group'
			}
		}, */
	/* 	{
			label: '出发城市',
			field: 'cityId',
			component: 'ApiSelect',
			componentProps: ({ formActionType, formModel }) => {
	
				return {
					//multiple: 多选；不填写为单选
					mode: '',
					//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
					api: () => defHttp.get({ url: '/coupleUser/getCitysByTenantId' }),
					//数值转成String
					numberToString: false,
					//标题字段
					labelField: 'name',
					//值字段
					valueField: 'id',
					//请求参数
					params: {
					},
					//返回结果字段
					resultField: 'records'
				}
	
			}, */
	/* 	show: ({ values }) => {
			return values.type == 'TravelLine' || values.type == 'Group'
		} 
},*/
	{
		label: '常规大团',
		field: 'itemid',
		component: 'ApiSelect',
		componentProps: ({ formActionType, formModel }) => {

			if (formModel.typeAcitvity) {
				return {
					//multiple: 多选；不填写为单选
					mode: '',
					//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
					api: () => defHttp.get({ url: '/journey/bsTravelgroupMaintuortravellinerecord/getJourneysByActivite' }),
					//数值转成String
					numberToString: false,
					//标题字段
					labelField: 'title',
					//值字段
					valueField: 'id',
					//请求参数
					params: {
					},
					//返回结果字段
					resultField: 'records'
				}
			}

		},
		//required: true
		show: ({ values }) => {
			return values.type == 'TravelLine' || values.type == 'Group'
		}
	},

	/* 	{
			label: '路线',
			field: 'itemid',
			component: 'JSearchSelect',
			componentProps: {
				dict: 'BS_TravelGroup_MainTuorTravelLineRecord,travelTitle,id',
				async: true,
				pageSize: 10
	
			},
			dynamicRules: ({ model, schema }) => {
				return [
					{ required: true, message: '请选择路线!' },
				];
			},
			show: ({ values }) => {
				return values.type == 'TravelLine'
			}
		}, */
	{
		label: '活动开始时间',
		field: 'startdate',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入开始时间!' },
			];
		},
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
	},
	{
		label: '活动结束时间',
		field: 'enddate',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入结束时间!' },
			];
		},

	},
	{
		label: '排序',
		field: 'sortnum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入排序!' },
			];
		},
	},

	/* {
		label: '原价',
		field: 'originprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入原价!' },
			];
		},
	}, */
	{
		label: '早鸟价',
		field: 'activeprice',
		component: 'InputNumber',
		/* 	dynamicRules: ({ model, schema }) => {
				return [
					{ required: true, message: '请输入早鸟价!' },
				];
			}, */
	},
	{
		label: '早鸟价截至时间',
		field: 'priceexpiretime',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
		/* dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入早鸟价截至时间!' },
			];
		}, */
	},
	/* {
		label: '主标题',
		field: 'mainTitle',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入标题组!' },
			];
		},
		colProps: {
			span: 24
		}
	},
	{
		label: '副标题',
		field: 'secondTitle',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入标题组!' },
			];
		},
		colProps: {
			span: 24
		}
	}, */
	{
		label: '标签',
		field: 'tags',
		helpMessage: '标签用逗号分割',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入标题组!' },
			];
		},
		colProps: {
			span: 24
		}
	},
	{
		label: '封面图',
		field: 'image',
		component: 'JUpload',
		helpMessage: '最多上传1张图片',
		componentProps: {
			fileType: UploadTypeEnum.image,
			maxCount: 1,
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请上传图片!' },
			];
		},
	},
	/* {
		label: '其他信息',
		field: 'extinfors',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其他信息!' },
			];
		},
	}, */
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '',
		field: 'activityTypes',
		component: 'Input',
		show: false
	},
	{
		label: '',
		field: 'activityKeys',
		component: 'Input',
		show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}